package com.zhang.yygh.hosp.controller.user;

import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleOrderVo;
import com.zhang.yygh.common.result.R;
import com.zhang.yygh.hosp.service.ScheduleService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/user/hosp/hospital")
public class UserScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    @ApiOperation(value = "获取可预约排班数据")
    @GetMapping("getBookingScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public R getBookingScheduleRule(@PathVariable Integer page,
                                    @PathVariable Integer limit,
                                    @PathVariable String hoscode,
                                    @PathVariable String depcode){
        Map<String,Object> map=scheduleService.getBookingScheduleRule(page,limit,hoscode,depcode);
        return R.ok().data(map);
    }

    @ApiOperation(value = "获取排班数据")
    @GetMapping("findScheduleList/{hoscode}/{depcode}/{workDate}")
    public R findScheduleList(
            @PathVariable String hoscode,
            @PathVariable String depcode,
            @PathVariable String workDate) {
        List<Schedule> list = scheduleService.findScheduleList(hoscode, depcode, workDate);
        return R.ok().data("list",list);
    }

    @ApiOperation(value = "获取排班详情")
    @GetMapping("getSchedule/{id}")
    public R getScheduleInfoById(@PathVariable String id){
        Schedule schedule=scheduleService.getScheduleInfoById(id);
        return R.ok().data("schedule",schedule);
    }

    //这个接口是给service_order模块远程调用使用的
    @ApiOperation(value = "根据排班id获取排版信息 预约下单数据")
    @GetMapping("inner/getScheduleOrderVo/{scheduleId}")
    public ScheduleOrderVo getScheduleById(
            @ApiParam(name = "scheduleId", value = "排班id", required = true)
            @PathVariable("scheduleId") String scheduleId) {
        return scheduleService.getScheduleOrderInfoById(scheduleId);
    }
}
